﻿using System;
using Microsoft.EntityFrameworkCore.Migrations;

#nullable disable

namespace Himp.Platform.Dc.Migrations
{
    /// <inheritdoc />
    public partial class add_table_UsedFrquDict : Migration
    {
        /// <inheritdoc />
        protected override void Up(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.CreateTable(
                name: "DRUG_MEDC_WAY_DICT",
                schema: "Dc",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    DRUG_MEDC_WAY_CODG = table.Column<string>(type: "text", nullable: false),
                    DRUG_MEDC_WAY_NAME = table.Column<string>(type: "text", nullable: false),
                    DRUG_MEDC_WAY_TYPE_CODE = table.Column<string>(type: "text", nullable: false),
                    DRUG_MEDC_WAY_TYPE_NAME = table.Column<string>(type: "text", nullable: false),
                    DATA_DICT_CODE = table.Column<string>(type: "text", nullable: false),
                    DATA_DICT_NAME = table.Column<string>(type: "text", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_DRUG_MEDC_WAY_DICT", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "INV_CHG_TYPE_DICT",
                schema: "Dc",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    INV_CHG_TYPE_CODE = table.Column<string>(type: "text", nullable: false),
                    INV_CHG_TYPE_NAME = table.Column<string>(type: "text", nullable: false),
                    VER = table.Column<int>(type: "integer", nullable: false),
                    PINYIN_MEMO = table.Column<string>(type: "text", nullable: true),
                    WUBI_MEMO = table.Column<string>(type: "text", nullable: true),
                    DATA_DICT_CODE = table.Column<string>(type: "text", nullable: false),
                    DATA_DICT_NAME = table.Column<string>(type: "text", nullable: false),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_INV_CHG_TYPE_DICT", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "OPRN_DICT",
                schema: "Dc",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    OPRN_CODE = table.Column<string>(type: "text", nullable: false),
                    OPRN_NAME = table.Column<string>(type: "text", nullable: false),
                    Ver = table.Column<int>(type: "integer", nullable: false),
                    PINYIN_MEMO = table.Column<string>(type: "text", nullable: true),
                    WUBI_MEMO = table.Column<string>(type: "text", nullable: true),
                    IsDeleted = table.Column<bool>(type: "boolean", nullable: false, defaultValue: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_OPRN_DICT", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "RX_TYPE_DICT",
                schema: "Dc",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    RX_TYPE_CODG = table.Column<string>(type: "text", nullable: false),
                    RX_TYPE_NAME = table.Column<string>(type: "text", nullable: false),
                    DATA_DICT_CODE = table.Column<string>(type: "text", nullable: false),
                    DATA_DICT_NAME = table.Column<string>(type: "text", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_RX_TYPE_DICT", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "SPLER_DICT",
                schema: "Dc",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    SPLER_CODG = table.Column<string>(type: "text", nullable: false),
                    SPLER_NAME = table.Column<string>(type: "text", nullable: false),
                    SPLER_TYPE = table.Column<int>(type: "integer", nullable: false),
                    SPLER_PMTNO = table.Column<string>(type: "text", nullable: true),
                    PINYIN_MEMO = table.Column<string>(type: "text", nullable: true),
                    WUBI_MEMO = table.Column<string>(type: "text", nullable: true),
                    CONER = table.Column<string>(type: "text", nullable: true),
                    EMAIL = table.Column<string>(type: "text", nullable: true),
                    TEL = table.Column<string>(type: "text", nullable: true),
                    OP_BANK_TYPE_CODE = table.Column<string>(type: "text", nullable: true),
                    OP_BANK_TYPE_NAME = table.Column<string>(type: "text", nullable: true),
                    LPR_NAME = table.Column<string>(type: "text", nullable: true),
                    VALI_FLAG = table.Column<bool>(type: "boolean", nullable: false),
                    TIN = table.Column<string>(type: "text", nullable: true),
                    REGN = table.Column<string>(type: "text", nullable: true),
                    CHKER_CODG = table.Column<string>(type: "text", nullable: true),
                    CHKER_NAME = table.Column<string>(type: "text", nullable: true),
                    CHK_TIME = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_SPLER_DICT", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "STD_DOMAIN_DICT",
                schema: "Dc",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    StdWordDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    DOMAIN_GROUP = table.Column<int>(type: "integer", nullable: false),
                    DOMAIN_CODE = table.Column<string>(type: "text", nullable: false),
                    DOMAIN_NAME = table.Column<string>(type: "text", nullable: false),
                    LOGICAL_DATA_TYPE = table.Column<int>(type: "integer", nullable: false),
                    PHYS_DATA_TYPE = table.Column<int>(type: "integer", nullable: false),
                    DATA_LEN = table.Column<string>(type: "text", nullable: false),
                    EXP = table.Column<string>(type: "text", nullable: true),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_STD_DOMAIN_DICT", x => x.Id);
                    table.ForeignKey(
                        name: "FK_STD_DOMAIN_DICT_STD_WORD_DICT_StdWordDictId",
                        column: x => x.StdWordDictId,
                        principalSchema: "Dc",
                        principalTable: "STD_WORD_DICT",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateTable(
                name: "USED_FRQU_DICT",
                schema: "Dc",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    USED_FRQU_CODG = table.Column<string>(type: "text", nullable: false),
                    USED_FRQU_NAME = table.Column<string>(type: "text", nullable: false),
                    DSCR = table.Column<string>(type: "text", nullable: false),
                    PRD = table.Column<int>(type: "integer", nullable: false),
                    CNT = table.Column<int>(type: "integer", nullable: false),
                    USED_FRQU_TYPE_CODE = table.Column<string>(type: "text", nullable: false),
                    USED_FRQU_TYPE_NAME = table.Column<string>(type: "text", nullable: false),
                    DATA_DICT_CODE = table.Column<string>(type: "text", nullable: false),
                    DATA_DICT_NAME = table.Column<string>(type: "text", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_USED_FRQU_DICT", x => x.Id);
                });

            migrationBuilder.CreateTable(
                name: "STD_PHR_DICT",
                schema: "Dc",
                columns: table => new
                {
                    Id = table.Column<Guid>(type: "uuid", nullable: false),
                    StdDomainDictId = table.Column<Guid>(type: "uuid", nullable: false),
                    PHR_CODE = table.Column<string>(type: "text", nullable: false),
                    PHR_NAME = table.Column<string>(type: "text", nullable: false),
                    EXP = table.Column<string>(type: "text", nullable: false),
                    TenantId = table.Column<Guid>(type: "uuid", nullable: true),
                    ExtraProperties = table.Column<string>(type: "text", nullable: false),
                    ConcurrencyStamp = table.Column<string>(type: "character varying(40)", maxLength: 40, nullable: false),
                    CreationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
                    CreatorId = table.Column<Guid>(type: "uuid", nullable: true),
                    LastModificationTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
                    LastModifierId = table.Column<Guid>(type: "uuid", nullable: true)
                },
                constraints: table =>
                {
                    table.PrimaryKey("PK_STD_PHR_DICT", x => x.Id);
                    table.ForeignKey(
                        name: "FK_STD_PHR_DICT_STD_DOMAIN_DICT_StdDomainDictId",
                        column: x => x.StdDomainDictId,
                        principalSchema: "Dc",
                        principalTable: "STD_DOMAIN_DICT",
                        principalColumn: "Id",
                        onDelete: ReferentialAction.Cascade);
                });

            migrationBuilder.CreateIndex(
                name: "IX_STD_DOMAIN_DICT_StdWordDictId",
                schema: "Dc",
                table: "STD_DOMAIN_DICT",
                column: "StdWordDictId");

            migrationBuilder.CreateIndex(
                name: "IX_STD_PHR_DICT_StdDomainDictId",
                schema: "Dc",
                table: "STD_PHR_DICT",
                column: "StdDomainDictId");
        }

        /// <inheritdoc />
        protected override void Down(MigrationBuilder migrationBuilder)
        {
            migrationBuilder.DropTable(
                name: "DRUG_MEDC_WAY_DICT",
                schema: "Dc");

            migrationBuilder.DropTable(
                name: "INV_CHG_TYPE_DICT",
                schema: "Dc");

            migrationBuilder.DropTable(
                name: "OPRN_DICT",
                schema: "Dc");

            migrationBuilder.DropTable(
                name: "RX_TYPE_DICT",
                schema: "Dc");

            migrationBuilder.DropTable(
                name: "SPLER_DICT",
                schema: "Dc");

            migrationBuilder.DropTable(
                name: "STD_PHR_DICT",
                schema: "Dc");

            migrationBuilder.DropTable(
                name: "USED_FRQU_DICT",
                schema: "Dc");

            migrationBuilder.DropTable(
                name: "STD_DOMAIN_DICT",
                schema: "Dc");
        }
    }
}
